package com.victor.controller.mobile;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.victor.entity.Mybybookcoupon;
import com.victor.service.BybookcouponService;
import com.victor.utils.Msg;

/**
 * 手机端购书卷相关
 * 
 * @author zhangbin
 *
 */
@RestController
@RequestMapping("/mybybookcoupon")
public class MybybookcouponController {

	@Autowired
	private BybookcouponService bybookcouponService;

	// 获取我的购书卷
	@RequestMapping("/getmybybookcoupon")
	public Msg getmybybookcoupon(String userid) {
		// 获取购书卷之前先更新卷表中所有卷状态
		bybookcouponService.updateBookcoupon();
		
		List<Mybybookcoupon> mybybookcoupons = bybookcouponService.getmybybookcoupon(userid);
		if (mybybookcoupons != null && mybybookcoupons.size() > 0) {
			return Msg.success().add("mybybookcoupons", mybybookcoupons);
		}
		return Msg.fail("暂无购书卷");
	}
	
}
